package com.hoki.zj.config;

import com.hoki.zj.batch.service.IBlogInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 定时任务配置类: ScheduledTaskConfig
 */
@Configuration
@EnableScheduling // 开启定时任务
@Slf4j
public class ScheduledTaskConfig {

    @Autowired
    private IBlogInfoService blogInfoService;

    /**
     * 定时任务:秒杀课程发布
     */
    @Scheduled(cron = "0/5 * * * * ?") // 测试设为5s一次
//    @Scheduled(cron = "0 0 23 * * ?") // 每天23点执行
    public void addKillCoursePublishTask() {
        log.info("定時的にバッチ任務を行う");
        blogInfoService.testJobTasklet();
    }
}
